2,646 Posted Topics

Member Avatar for dumicom

This question is a duplicate of [this one](http://stackoverflow.com/questions/25012886/plotting-3-columns-or-more-data-on-the-graph-python) in another forum.

Member Avatar for Gribouillis
0
348
Member Avatar for Atomicquasar

I tried your code, and apparently it works: the decimal points are aligned. Can you post your output ? Python 3.4.0 (default, Apr 11 2014, 13:05:11) [GCC 4.8.2] on linux Type "help", "copyright", "credits" or "license" for more information. >>> num1 = 127.899 >>> num2 = 3456.148 >>> num3 = …

Member Avatar for Gribouillis
0
336
Member Avatar for dumicom

There are python modules to read xls files (such as xlrd). However in your case, it may be easier to convert the file to csv on the command line: if you have Libreoffice installed on your computer, you can use soffice --headless --convert-to csv data.xls in a terminal to convert data.xls …

Member Avatar for Gribouillis
0
2K
Member Avatar for dumicom

I suggest using pandas dataframes and their methods for statistics # -*- coding: utf-8 -*- import pandas as pd df = pd.read_table( 'data.csv', sep=',', header=0, parse_dates = [0] ) print(df) m = df.mean() print(type(m)) print(m) print float(m['Irradiance']) """ my output --> 0 2014-07-21 00:00:00 0.66 1 2014-07-21 00:00:00 0.71 2 …

Member Avatar for Gribouillis
0
2K
Member Avatar for dumicom

Install [humanfriendly](https://pypi.python.org/pypi/humanfriendly) from pypi (`pip install humanfriendly`), then from datetime import datetime from humanfriendly import parse_date s = raw_input('From datetime: ') dt = datetime(*parse_date(s)) print(dt)

Member Avatar for Gribouillis
0
1K
Member Avatar for abaddon2031

Your code is very difficult to understand. I think you can do a lot with a single regular expression, like in this example # -*- coding: utf-8 -*- """ Created on Fri Jul 25 19:23:53 2014 python 2 or 3 @author: Gribouillis """ import re pattern = re.compile( r"^(?P<prefix>(?:[^_.]|_(?!p))+)" r"_p(?P<type>(?:[^_.]|_(?!b))+)" …

Member Avatar for abaddon2031
0
361
Member Avatar for dumicom

Use time_format = '%d/%m/%Y %H:%M' try: datetime_obj = datetime.strptime(time_string, time_format) except ValueError: print("STRING: ", repr(time_string), "FORMAT: ", repr(time_format)) raise and post the output.

Member Avatar for dumicom
0
5K
Member Avatar for ndombko1

The csv module has a concept of *dialect*. For example in the data shown above, I don't see separating commas or quoting characters. See for [example here](http://www.daniweb.com/software-development/python/threads/443909/learning-re-module#post1912119) how one can use a dialect to read a csv file. Can you attach a short csv file to a post ? (perhaps …

Member Avatar for ndombko1
0
377
Member Avatar for Gribouillis

This snippet defines a function [icode]mousepos()[/icode] which gets the mouse position on the screen. The package python-xlib is required.

Member Avatar for woooee
1
6K
Member Avatar for ndombko1

This thread is a duplicate of this one: [click here](http://www.daniweb.com/software-development/python/threads/482152/inserting-zeros-depending-on-the-length). Discussion goes on in the other thread.

Member Avatar for Gribouillis
0
126
Member Avatar for A-M-G

Did you try oldwd = os.getcwd() os.chdir('C:/Users/UserName/Documents') try: zipdir('Folder_to_be_zipped', zipf) finally: os.chdir(oldwd) ?

Member Avatar for Gribouillis
0
5K
Member Avatar for DragonMastur

Here is a [tkinter example](http://www.daniweb.com/software-development/python/code/216830/tkinter-keypress-event-python) by vegaseat.

Member Avatar for Gribouillis
0
576
Member Avatar for lewashby

Did you check the type of `line` ? it seems to me that is a `str` (which means unicode in python 3). Again you are mixing bytes and str implicitly (`tag in line.lower()`). Use explicit conversions to control the types.

Member Avatar for snippsat
0
822
Member Avatar for lewashby

Try import eyeD3 To answer your second question, create for example a directory with $ mkdir ~/pymods in a terminal, then add the following lines to the file `~/.bashrc`, and restart the terminal PYTHONPATH="$HOME/pymods:$PYTHONPATH" export PYTHONPATH Now every python file added to the directory `~/pymods` becomes importable from anywhere (under …

Member Avatar for Gribouillis
0
1K
Member Avatar for abaddon2031

> In the spirit of more than one way to do it ... Notice that python came after perl, and in python, > There should be one-- and preferably only one --obvious way to do it. type import this in the python console to read the Zen of python. The …

Member Avatar for snippsat
0
269
Member Avatar for analys
Member Avatar for Jack_9

One part of the question is why would we need an OS written in python ? My advice is: go linux !

Member Avatar for mike_2000_17
0
264
Member Avatar for kxjakkk

As sepp2k said, create MyTime instances `t1 = MyTime(9, 59, 59)`, etc.

Member Avatar for kxjakkk
0
285
Member Avatar for EnergeticJet

This is the first [dadaist](https://en.wikipedia.org/wiki/Dada) thread here. Your code does not make sense. Do something useful instead !

Member Avatar for DragonMastur
0
382
Member Avatar for moone009

Here is a short explanation about variable visibility varA = "foo" # a global variable class Bar: # Bar is another global variable varB = "baz" # a class variable def method(self, arg): # self and arg are local variables varC = "qux" # a local variable self.name = "aname" …

Member Avatar for moone009
0
7K
Member Avatar for Vikram_2

The main concern is about encoding. If you know the file's encoding, you can open it with `codecs.open()` and read the file as a unicode stream. I never used a hindi file, so that you must figure out the encoding yourself. Once you have the correct unicode stream, the rest …

Member Avatar for Gribouillis
0
2K
Member Avatar for sandhya1202

Independantly from writing the code, you must first define your classification criterion: how will you decide if a file belongs to 'name' or 'english', or 'entertainment' ?

Member Avatar for Vikram Kolla
0
343
Member Avatar for krystosan

It seems to me that `urlretrieve()` answers your question. For ftp, the example at the top of the `ftplib` module's documentation shows how to download a file named README. Also a search for `ftp` on pypi may reveal promising modules such as `ftptool` and others.

Member Avatar for slate
0
304
Member Avatar for lewashby

First note that due to [operator precedence](https://docs.python.org/3.3/reference/expressions.html#operator-precedence) the expression A or B in C is the same thing as A or (B in C) In particular if A is a non empty bytes such as `b'artist='`, the value of the whole expression is `A`, which evaluates as `True` in a boolean …

Member Avatar for TrustyTony
0
398
Member Avatar for Jolie Tia

It is not true that `file`is a reserved word in python. `file` is the name of a standard type in python **2**. Using file as a variable name in python 2 is like using list as a variable name. It is not an error, but it could be annoying to …

Member Avatar for Jolie Tia
0
389
Member Avatar for tubs1

> In what way is the use of Parameters similar/different to Variables? Same thing? The correct python concept is the *namespace*. At any given moment in the execution of python code, a certain number of *names* are defined in the current namespace. There is no difference between parameters and variables …

Member Avatar for Gribouillis
0
570
Member Avatar for Ravi_exact

Why not use a decorator ? #!/usr/bin/env python # -*-coding: utf8-*- from __future__ import (absolute_import, division, print_function, unicode_literals) __doc__ = '''adding attributes to a function ''' def menu_config(**attrs): def decorator(func): func.menu_attrs = attrs return func return decorator @menu_config(Name = 'Test Menu', Default = True) def test(): print('foo') if __name__ == …

Member Avatar for slate
0
487
Member Avatar for abaddon2031
Re: Def

Apparently, the whole code depends on 2 values, `fileFull` and `fileAbriv`. So you can write a function def func(fileFull, fileAbriv): etc However, this code, with lines repeated with different variable name case is not good. There must be some other way to write your code. Read about the [DRY](https://en.wikipedia.org/wiki/Don't_repeat_yourself) principle. …

Member Avatar for abaddon2031
0
225
Member Avatar for lewashby

You're getting the error because `char` is of type `bytes`, and `char[counter]` is an integer. Also you initiliazed newchar as a `str`. At line 15, you can't add a str and an int. You could write newchar = b'' # initialize as bytes counter = 0 while counter < 30 …

Member Avatar for lewashby
0
4K
Member Avatar for Gribouillis

Today is 70th anniversary of D-Day in France, with 20 heads of state, including Queen Elizabeth and Barack Obama ! Great weather and nice speeches ! https://twitter.com/FranceinChicago/status/474910715237502977/photo/1 Let's remember these 150000 soldiers ! http://online.wsj.com/articles/d-day-invasion-view-from-above-1402005875?tesla=y#1

0
194
Member Avatar for Tcll

First thing to do is to print the structure to see what it contains. I found a pretty printer [here](http://alexleone.blogspot.fr/2010/01/python-ast-pretty-printer.html) #!/usr/bin/env python # -*-coding: utf8-*- from __future__ import (absolute_import, division, print_function, unicode_literals) __doc__ = ''' ''' import ast from astpp import dump source = """ def foo(n): p = 1 …

Member Avatar for Tcll
0
606
Member Avatar for dany12

Add print(repr(word)) print(list) immediately before line 19 and post the output here. Also 'list' and 'dict' are so common words in python that nobody uses them for variables.

Member Avatar for dany12
0
262
Member Avatar for omnik123

The most famous place in France is the Eiffel tower (almost 7 million visitors a year), but it's not a place I would recommend. Start with the south of France. Edit: I forgot the Louvre museum with almost 10 million visitors/year. The atmosphere is that of a railway station with paintings …

Member Avatar for Agilemind
0
752
Member Avatar for stormynem

I'm not an expert but I think `geometry()` applies to top level windows only. You may want to call OedipusFrame.winfo_toplevel().geometry(("%dx%d+0+0")%(OFWidth,OFHeight)) See also [here](http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/geometry.html).

Member Avatar for Gribouillis
0
241
Member Avatar for nouth
Member Avatar for silverdust

You can perhaps add the condition that there is no uppercase letter before the first 3 ones or after the 3 last ones.

Member Avatar for silverdust
0
439
Member Avatar for nouth

Python only wraps the lower level system functions which open a file to create a file descriptor or a pointer to file, and the corresponding read or write functions. So, for example you could ask in the C forum if `fopen()` with mode `'w'` physically overwrites existing contents on the …

Member Avatar for Gribouillis
0
265
Member Avatar for silverdust
Member Avatar for silverdust
0
384
Member Avatar for massivefermion
Member Avatar for Gribouillis
0
129
Member Avatar for Tcll

I see 2 tools which could give you more detail: 1. You can use `sys.settrace()` to define your own trace function and count the number of calls in each line (there is some programming effort to get something here). 2. You can use `f.f_lasti` on the calling frame to get …

Member Avatar for Tcll
0
559
Member Avatar for Tamara_1

It is very nice. I see 2 directions onwards: 1. Add interaction with the user to get the coefficients (raw_input, etc). 2. Use the fractions module from standard lib to work with exact rational coefficients.

Member Avatar for ddanbe
1
540
Member Avatar for Spencer_3

The simplest way is import easygui word = easygui.passwordbox() You can then browse the easygui source code to learn how to make a passwordbox :) and remove the buttons if you want to.

Member Avatar for woooee
0
4K
Member Avatar for abaddon2031

Your explanation is unclear. I don't think there is an issue. For example if the first file contains args = parser.parse_args() you can later call `foo(args)` and it doesn't matter if function `foo()` was defined in the first or the second script.

Member Avatar for Gribouillis
0
419
Member Avatar for abaddon2031

The best thing to do is to add `print(args)` to your script and test it in a console with commands such as $ python filename.py -h $ python filename.py -b /home/foobar I would add a long name such as `'--basepath'` to the `'-b'` option and use `BASEPATH` as metavar. Also …

Member Avatar for abaddon2031
0
682
Member Avatar for Gribouillis

This snippet implements a pointed set, that is to say an ordinary set of elements with a distinguished element called the basepoint of the set. For example the seven days of the week could be stored in a pointed set, the basepoint being monday because today is monday. It is …

6
268
Member Avatar for zeroth

May I suggest that you install [locate32](http://www.windows8downloads.com/software-search.html?keywords=locate32&Search=) to find your files in win 8 ?

Member Avatar for cunnijo
0
300
Member Avatar for nitin1

My father in law bought an asus which broke down rapidly. On the other hand, I had one which worked very well during almost 10 years. I bought 3 acer aspire laptops for 500/700 euros in the last 2 years, and they do their job. The first thing I do is …

Member Avatar for blackmiau
0
444
Member Avatar for giancan
Member Avatar for abaddon2031
Member Avatar for mark103

I would go with BeautifulSoup as it produces short code, for example # -*-coding: utf8-*- from __future__ import (absolute_import, division, print_function, unicode_literals) from BeautifulSoup import BeautifulSoup def main(): filename = 'input.xml' soup = BeautifulSoup(open(filename).read()) for channel in soup.findAll('channel'): cid = channel['id'] # or dict(channel.attrs)['id'] for prog in channel.findAll('programme'): for title …

Member Avatar for Gribouillis
0
252

The End.