Re: Command Line Inputs from Windows

2015-01-02 Thread Mark Lawrence

On 02/01/2015 21:29, Chris Angelico wrote:

On Sat, Jan 3, 2015 at 6:44 AM, Ken Stewart  wrote:

This works:


I may have some details wrong, and it's likely to be a little
different on Win7, but poke around and look for a missing %*. Or,
better still, make sure you have the py.exe launcher; then you can
have Python scripts request a specific interpreter using a PEP 397
compliant shebang, which will also work nicely on Unix systems.



The launcher has been included since 3.3 
https://docs.python.org/3/whatsnew/3.3.html#pep-397-python-launcher-for-windows


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list


Re: Command Line Inputs from Windows

2015-01-02 Thread Chris Angelico
On Sat, Jan 3, 2015 at 2:41 PM, James Scholes  wrote:
> Chris Angelico wrote:
>> The latter form is governed by the association. I don't know off-hand
>> where that's set in the registry, but you should be able to poke
>> around in folder settings to find it (but, thank you very much
>> Microsoft, the exact menu path has changed a number of times between
>> Win2K and Win8). On WinXP, if I have my test-box set up correctly,
>> it's View, Folder Options, File Types, select the one for .py,
>> Advanced, select "open", Edit.
>
> As of Windows 7 (possibly Vista although don't quote me on that), this
> functionality is no longer available.  You'll need to either edit the
> registry directly or use a third party tool to manage filetypes and
> their associated actions.

Blargh. Can you recommend a third-party tool? If not, the best advice
I can give is "poke around on the Google".

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I remove/unlink wildcarded files

2015-01-02 Thread Gregory Ewing

Chris Angelico wrote:

On Sat, Jan 3, 2015 at 4:15 AM, Rick Johnson
 wrote:


Those who refuse to be a part of the modern world can
suffer the troubles of forking the code into their ancient
systems -- and i will not loose any sleep over the issue.


By the way, is this "loose" part of your "modern world", or is that
just a straight-up error?


I think he's just let slip a clue to his secret
evil plans. Anyone who stands between him and
world domination will be anaesthetised by his
fearsome giant sleep cannon.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


PythonFOSDEM 2015 - Selected Talks

2015-01-02 Thread Stéphane Wirtel

Hi all,

We are really proud to announce the official listing for the selected 
talks of the PythonFOSDEM 2015 (during the FOSDEM 2015 : 
https://fosdem.org/2015/).


This year, it's a real surprise for us, firstly we received 42 proposals 
for this edition 2015

and secondly, we move to a bigger room with 200 seats.

You are cordially invited to this PythonFOSDEM 2015.

The room is H.1301 with a capacity of 200 seats.

The event will start at 09:00 AM (local) and will finish at 06:00 PM.

We think to propose a Ligthning Talk Session of one hour.

Here is the talks of this year.

* 09:00 - TaskFlow: State Management Framework
by Vishal Yadav

* 09:30 - Lea, a probability engine in Python Probabilities made easy!
by Pierre Denis

* 10:00 - Dive into Scrapy
by Juan Riaza

* 10:30 - Mercurial, with real python bites
by Pierre-Yves David

* 11:00 - python-prompt-toolkit / ptpython
by Jonathan Slenders

* 11:30 - Federation and Python webapps
by Christopher Webber

* 12:00 - Let's build a spreadsheet app in Python
by Harry Percival

* 12:30 - PDB is your friend
by Raul Cumplido Dominguez

* 14:00 - Customize Gunicorn for your own business.
by Benoit Chesneau

* 14:30 - Python, WebRTC and you
by Saùl Ibarra Corretgé

* 15:00 - When performance matters ...
by Marc-André Lemburg

* 15:30 - Gradual Typing in Python
by Alejandro Gomez

* 16:00 - Knowing your garbage collector
by Francisco Fernàndez Castano

* 16:30 - RedBaron a bottom up approach to refactoring in python
by Laurent Peuch

* 17:00 - Extending Python, what is the best option for me?
by Francisco Fernàndez Castano

* 17:30 - PyPy and the future of the Python ecosystem
by Romain Guillebert

You can find this list on the site of FOSDEM: 
https://fosdem.org/2015/schedule/track/python/

and on the site of PythonFOSDEM.

Of course, after the talks, there will be a dinner in a restaurant of 
Brussels with the Python Community, here is the link to the doodle [1] 
for the subscription to the dinner.
We need to know the exact numbers for the restaurant. So, please, could 
you subscribe as soon as possible and try to be present for the dinner.


Thank you a lot for your patience and Thank you for the proposals.

[1] http://doodle.com/ngdeesgbr6dcx3f5


--
Stéphane Wirtel - http://wirtel.be - @matrixise
--
https://mail.python.org/mailman/listinfo/python-list


Re: Looking for sample python script using Tkinter

2015-01-02 Thread Rick Johnson
On Friday, January 2, 2015 5:03:35 PM UTC-6, access...@gmail.com wrote:
> I have a script that I trying to go from command line
> entry to interface entry. [...] I have a few requirements
> when capturing the data:
>Must be able to navigate to a file and capture entire
>filename and pathname (which may be on a network rather
>than the C drive)

I don't foresee an issue here. Like Christian said, give the
tkFileDialog a spin.

>Capture date
>
>Capture text (Some of the data entry fields will have
>commas)
>
>Some of the data entry fields are required, some are
>not.

The "capturing" part has nothing to do with GUI's, and the
code should map "almost unchanged" from your command-line 
code.

> Is there a sample script out there that I can review to
> see how these features are accomplished? I am particularly
> stumped by #1 and 4.

Maybe, but i would not know. I think instead of expecting
that a script in the wild might be a one-to-one mapping of
your current problem, you should break the many problems
within this script into distinct areas of research.  But
first you should research the following prerequisites:

  1. How to: create a blank Tkinter window?
 Hint: tk.Tk()

  2. How to: place "N" input fields on a Tkinter window?
 Hint: tk.Entry(...)

  3. How to: dynamically create "N" input fields on demand?
 Hint: "for" he's a jolly good fellow!

  4. How to: customize and/or restrict the input of an input field?
 Hint: "widget.bind("", func)"

  5. How to: "validate" a group of input fields?
 Hint: "for" he's a jolly good fellow!

  6. How to: allow the user to locate a file (local or otherwise?)
 Hint: "import tkFileDialog"


  http://effbot.org/tkinterbook/
  http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/index.html

I think you'll catch more informative answers if you
restrict the problem domain a bit.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I remove/unlink wildcarded files

2015-01-02 Thread Rick Johnson
On Friday, January 2, 2015 11:54:49 AM UTC-6, Rustom Mody wrote:
> And how does this strange language called English fits
> into your rules and (no) special cases scheme?

Oh i'm not blind to the many warts of the English language,
for it has many undesirable qualities indeed, however, it
*is* the "most ubiquitous language spoken" in the world.

Note that "most ubiquitous spoken" does not mean that
"the majority of people in the world speak English",
rather that: "English crosses more cultural divides than
any language spoken today" -- and because of that fact
(for better or worse???) our public communications
should be in English only.

I not suggesting that "supporting" multiple languages is a
sin, merely that, supporting multiple languages is a waste
of valuable time -- time that could be better spent tracking
bugs or adding features.

That is the sole reason why i detest UNICODE. UNICODE's
existence provides "life-support" for natural language
multiplicity, because it acts as a translator for selfish
alias's of ideas. Without this "translator", the technical
society would render these languages obsolete in short time.


REGIONAL LANGUAGES REPRESENT "SELFISH SYMBOL TABLES", WHO'S
KEYS ARE MERELY "SUPERFLUOUS CODIFICATIONS" OF THE UBIQUITOUS
"IMMUTABLE GLOBAL CONCEPTS" FOR WHICH THEY MAP, AND WE NEED
AN OPTIMIZER TO FOREVER FREE OUR COMMUNICATIONS OF THESE
"REDUNDANT BINDINGS"; INJECTED BY EMOTIONAL LITTLE AMATEURS,
WHO's INTELLECTUAL BOUNDARIES END AT THE BASE OF THEIR OWN
INSIGNIFICANT LITTLE ANT HILL!

THE UNIVERSE SHOULD BE THE ONLY LIMIT!


A tree is a tree, not matter how you spell it. A dog is dog,
velocity/mass/etc... These definitions (an many others) of
both "tangible objects" and "intangible ideas" are not in
dispute, SO WHY PERPETUATE SELFISH CODES TO DESCRIBE THEM?

Relationships such as: "dogs and cats are mammals", are
likewise not disputable, but yet we continue to codify
knowledge behind a multiplicity of selfish regional symbols --
and for what benefit?

Look, i know humans have this "instinctual need" to assemble
in herds, herds which employ unique symbols which "coddle"
their need for "sense of being" within the herd, but
these "needs" are not intellectual, they are but *cheap*
emotional remnants from our primitive days, and whist these
"herd emotions" are invaluable to the survival of primitive
lifeforms, we must realize that they serve no intellectual
purpose, and in fact, are an anchor around the necks of
advanced lifeforms such as ourselves.


WE MUST RELY ON LOGIC TO MOVE US INTO THE NEXT EVOLUTIONARY
STAGE -- BECAUSE EMOTION WILL DESTROY US!


Logic is not instinctual, neither is reason -- but emotion
*IS*! Emotion is our "basic modality" to fall back on when
the "logical system" fails us. A clear example of this "base
system" in action is the "oft-cited cop-out" of:

"Oh, that's just semantics!"

Such a remark is nothing more than a weak "ego defense"
employed by an opponent who is either: (1) too lazy to
contemplate the intellectual depths, or (2) lacks the
intellectual *fortitude* to grasp the inherent concepts.

At some point we *ALL* need to realize that most ideas need
to be codified into a stdlib of world-wide natural language,
and then internalized within all public communication. Am i
suggesting that no one would be allowed to speak in regional
tongues...?

OF COURSE NOT!

I'm merely suggesting that only *ONE* official language be
supported for public business and public communication
purposes. You are free to speak or write whatever "slang" or
"regionally selfish code" that you want in any "non-
official" communique.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Looking for sample python script using Tkinter

2015-01-02 Thread Christian Gollwitzer

Am 03.01.15 um 00:03 schrieb accessnew...@gmail.com:

I have a script that I trying to go from command line entry to interface entry. 
I am tinkering with Tkinter and want to review some Tkinter interface building 
scripts. Really basic stuff covering file selection and making some of the data 
captured required I am learning how to use Tkinter (Python 2.7) to build a data 
entry interface where the variables (about 15 data entry fields in all) will be 
used later in the script to perform some analyses. I have a few requirements 
when capturing the data:

 1   Must be able to navigate to a file and capture entire filename and 
pathname (which may be on a network rather than the C drive)
 2   Capture date
 3   Capture text (Some of the data entry fields will have commas)
 4   Some of the data entry fields are required, some are not.

Is there a sample script out there that I can review to see how
these  features are accomplished? I am particularly stumped by #1 and 4.


1: Does tkFileDialog.askopenfilename() fulfill your needs? On Windows, 
this should open the native file dialog. Usually, one packs a button 
near an entry widget to open the file dialog and the return value is 
placed in the entry


2: There are some date megawidgets. But you might prefer to just have an 
entry and validate the input / convert it to a date


3: The basic entry widget should do. It has no problems with commas. the 
only critical character is a tab, because it switches to the next field


4: GUI widgets don't have the notion of being required or not, that is 
entirely up to your application. Usually, there will be an "Apply" or 
"Submit" button or similar (or the action is bound to the Return key). 
On that occasion, don't accept the data if the required fields are left 
blank.


In general, you need to validate all input fields before you accept 
them. This is specific to your application and can't be handled by the 
toolkit itself. For common tasks like single real numbers, there are 
ready-made validators available that can validate the input already 
during editing. Note this is more difficult to get right than it seems 
at first glance; e.g. copy/pasting can be damaged if the validator is 
too simple. It is much easier to validate only before the data is accepted.


There are also several choices how you react if the validation fails. 
You could show the error in a popup (tkMessageBox). This is the simplest 
approach, but makes the error unavailable to the user after it is 
acknowledged. A better method from a usability perspective is a status 
line that signals the error, possibly in red, and also marks the fields 
with errors in red. All of this can be done in a couple of lines easily, 
but is lots of work to do completely right and capture every possible case.


Christian
--
https://mail.python.org/mailman/listinfo/python-list


Looking for sample python script using Tkinter

2015-01-02 Thread accessnewbie
I have a script that I trying to go from command line entry to interface entry. 
I am tinkering with Tkinter and want to review some Tkinter interface building 
scripts. Really basic stuff covering file selection and making some of the data 
captured required I am learning how to use Tkinter (Python 2.7) to build a data 
entry interface where the variables (about 15 data entry fields in all) will be 
used later in the script to perform some analyses. I have a few requirements 
when capturing the data:

Must be able to navigate to a file and capture entire filename and pathname 
(which may be on a network rather than the C drive)
Capture date
Capture text (Some of the data entry fields will have commas)
Some of the data entry fields are required, some are not.

Is there a sample script out there that I can review to see how these features 
are accomplished? I am particularly stumped by #1 and 4.

Thanks to any and all help.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [ANN] EasyGUI_Qt version 0.9

2015-01-02 Thread André Roberge
On Friday, 2 January 2015 16:22:21 UTC-4, Emil Oppeln-Bronikowski  wrote:
> On Fri, Jan 02, 2015 at 11:53:26AM -0800, André Roberge wrote:
> > How could it then be used?
> 
> Maybe I failed to explain myself fully. What I meant to say is building a 
> distribution-ready program that utilizes your library; not your library being 
> turn into a executable.

Ah, this makes sense.  But I have not had the need to do so mysefl.
> 
> Or maybe something is going over my head? Tell you what, once I get to some 
> decent network I'll try it on my own. :)
Please, let me know what you think - direct email is probably better.
> -- 
> People are like potatos. They die when you eat them.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Command Line Inputs from Windows

2015-01-02 Thread Chris Angelico
On Sat, Jan 3, 2015 at 6:44 AM, Ken Stewart  wrote:
> This works:
> python myScript.py arg1 arg2 arg3
>
> This doesn’t work:
> myScript.py arg1 arg2 arg3

The latter form is governed by the association. I don't know off-hand
where that's set in the registry, but you should be able to poke
around in folder settings to find it (but, thank you very much
Microsoft, the exact menu path has changed a number of times between
Win2K and Win8). On WinXP, if I have my test-box set up correctly,
it's View, Folder Options, File Types, select the one for .py,
Advanced, select "open", Edit. That'll tell you that the application
used is something like:

"C:\Python27\python.exe" "%1" %*

The %* should mean that arguments get carried through; if that's
missing, you won't get any args.

I may have some details wrong, and it's likely to be a little
different on Win7, but poke around and look for a missing %*. Or,
better still, make sure you have the py.exe launcher; then you can
have Python scripts request a specific interpreter using a PEP 397
compliant shebang, which will also work nicely on Unix systems.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I remove/unlink wildcarded files

2015-01-02 Thread Chris Angelico
On Sat, Jan 3, 2015 at 4:15 AM, Rick Johnson
 wrote:
> Those who refuse to be a part of the modern world can
> suffer the troubles of forking the code into their ancient
> systems -- and i will not loose any sleep over the issue.

By the way, is this "loose" part of your "modern world", or is that
just a straight-up error?

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I remove/unlink wildcarded files

2015-01-02 Thread Chris Angelico
On Sat, Jan 3, 2015 at 4:54 AM, Rustom Mody  wrote:
> And how does this strange language called English fits into your rules
> and (no) special cases scheme?
>
> http://www.omgfacts.com/lists/3989/Did-you-know-that-ough-can-be-pronounced-TEN-DIFFERENT-WAYS

I learned six, which is no more than there are for the simple vowel
'a' (at least, in British English; American English has a few less
sounds for 'a'). Consider "cat", "bay", "car" (that's the three most
common sounds), "watch", "water", "parent" (these three are less
common, and American English often folds them into the other three).
Now have a look at Norwegian, where the fifth of those sounds
("water") is spelled with a ring above, eg "La den gå" - and the sixth
is (I think) more often spelled with a slashed O - "Den kraften jeg
skjulte før". Similarly in Swedish: "Slå dig loss, slå dig fri" is
pronounced "Slaw di loss, slaw di free". Or let's look at another of
English's oddities. Put a t and an h together, and you get a
completely different sound... two different sounds, in fact, voiced or
unvoiced. Icelandic uses thorn instead: "Þetta er nóg" is pronounced
(roughly) "Thetta air know". And the whole notion of putting a dot on
a lower-case i and not putting one on upper-case I is pretty
illogical, but Turkish, as I mentioned in the previous post, uses the
dots to distinguish between two pronunciations of the vowel, hence
"aldırma" which would sound somewhat different with a dot on the i.

(You may be able to see a theme in my example texts, but I figured
it's time to see what I can do with full Unicode support. The cold
looks of disapproval never bothered me, anyway.)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [ANN] EasyGUI_Qt version 0.9

2015-01-02 Thread Emil Oppeln-Bronikowski
On Fri, Jan 02, 2015 at 11:53:26AM -0800, André Roberge wrote:
> How could it then be used?

Maybe I failed to explain myself fully. What I meant to say is building a 
distribution-ready program that utilizes your library; not your library being 
turn into a executable.

Or maybe something is going over my head? Tell you what, once I get to some 
decent network I'll try it on my own. :)
-- 
People are like potatos. They die when you eat them.

-- 
https://mail.python.org/mailman/listinfo/python-list


Command Line Inputs from Windows

2015-01-02 Thread Ken Stewart

Court of King Arthur,

I’d appreciate any help you can provide.  I’m having problems passing 
command line parameters from Windows 7 into a Python script (using Python 
3.4.2).  It works correctly when I call the interpreter explicitly from the 
Windows command prompt, but it doesn’t work when I enter the script name 
without calling the Python interpreter.


This works:
python myScript.py arg1 arg2 arg3

This doesn’t work:
myScript.py arg1 arg2 arg3

The Windows PATH environment variable contains the path to Python, as well 
as the path to the Script directory.  The PATHEXT environment variable 
contains the Python extension (.py).


There are other anomalies too between the two methods of invoking the script 
depending on whether I include the extension (.py) along with the script 
name.  For now I’m only interested in passing the arguments without 
explicitly calling the Python interpreter.



Here is the script:

#! python

import sys

def getargs():
   sys.stdout.write("\nHello from Python %s\n\n" % (sys.version,))
   print ('Number of arguments =', len(sys.argv))
   print ('Argument List =', str(sys.argv))

if __name__ == '__main__':
   getargs()


Result_1 (working correctly):

C:\Python34\Scripts> python myScript.py arg1 arg2 arg3

Hello from Python 3.4.2 (v3.4.2:ab2c023a9432, Oct  6 2014, 22:15:05) [MSC 
v.1600 32 bit (Intel)]


   Number of arguments = 4
   Argument List = ['myScript.py', 'arg1', 'arg2', 'arg3']


Result_ 2 (Fail)

C:\Python34\Scripts> myScript.py arg1 arg2 arg3

Hello from Python 3.4.2 (v3.4.2:ab2c023a9432, Oct  6 2014, 22:15:05) [MSC 
v.1600 32 bit (Intel)]


   Number of arguments = 1
   Argument List = ['C:\\Python34\\Scripts\\myScript.py']

As a beginner I’m probably making a mistake somewhere but I can’t find it. 
I don’t think the shebang does anything in Windows but I’ve tried several 
variations without success.  I’ve tried writing the script using only 
commands, without the accouterments of a full program (without the def 
statement and without the if __name__ == ‘__main__’ …) to no avail.  I’m out 
of ideas.  Any suggestions?


Ken Stewart

--
https://mail.python.org/mailman/listinfo/python-list


Re: [ANN] EasyGUI_Qt version 0.9

2015-01-02 Thread André Roberge
On Friday, 2 January 2015 15:22:22 UTC-4, Emil Oppeln-Bronikowski  wrote:
> On Fri, Jan 02, 2015 at 11:11:05AM -0800, André Roberge wrote:
> 
> Sorry if this was asked before: have you tried building a portable version 
> using py2exe/Nuitka/etc? I always hit a wall when it comes to building 
> against huge libraries like Python-Qt.
> 
No, this would seem really silly since the widgets created by EasyGUI_Qt need 
to be used within a Python program, like Python's own "input()" function.  What 
would happen if you took a simple module containing the following:

def get_string(prompt):
return input(prompt)

and tried to package it into an exe?  How could it then be used?

> -- 
> People are like potatos. They die when you eat them.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [ANN] EasyGUI_Qt version 0.9

2015-01-02 Thread Emil Oppeln-Bronikowski
On Fri, Jan 02, 2015 at 11:11:05AM -0800, André Roberge wrote:

Sorry if this was asked before: have you tried building a portable version 
using py2exe/Nuitka/etc? I always hit a wall when it comes to building against 
huge libraries like Python-Qt.

-- 
People are like potatos. They die when you eat them.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [ANN] EasyGUI_Qt version 0.9

2015-01-02 Thread André Roberge
On Friday, 2 January 2015 06:29:37 UTC-4, wxjm...@gmail.com  wrote:
> Le mercredi 31 décembre 2014 23:24:50 UTC+1, André Roberge a écrit :
> > EasyGUI_Qt version 0.9 has been released.  This is the first announcement 
> > about EasyGUI_Qt on this list.
snip
> I toyed and I spent a couple of hours with it.
> I do not know to much what to say.
Well, this is more positive than your previous comment expressing doubt that it 
would work. ;-)   So, thank you!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I remove/unlink wildcarded files

2015-01-02 Thread Rustom Mody
On Friday, January 2, 2015 10:45:17 PM UTC+5:30, Rick Johnson wrote:
> On Friday, January 2, 2015 8:01:50 AM UTC-6, Chris Angelico wrote:
> > I'm not sure that I'd want to. Handling case insensitivity is fine
> > when you're restricting everything to ASCII, but it's rather harder
> > when you allow all of Unicode. For instance, U+0069 and U+0049 would
> > be considered case-insensitively equal in English, but in Turkish,
> > they're different letters; U+0069 upper-cases to U+0130, and U+0049
> > lower-cases to U+0131. 
> 
> So what? If you're going to go out of your way to accomadate
> a small regional perversion of language semantics, then your
> "fetish of multiculturalism" is even more
> dangerous than i have previously thought!
> 
> SPECIAL CASES ARE NOT *SPECIAL ENOUGH* TO BREAK THE RULES!

And how does this strange language called English fits into your rules 
and (no) special cases scheme?

http://www.omgfacts.com/lists/3989/Did-you-know-that-ough-can-be-pronounced-TEN-DIFFERENT-WAYS
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I remove/unlink wildcarded files

2015-01-02 Thread Rick Johnson
On Friday, January 2, 2015 8:01:50 AM UTC-6, Chris Angelico wrote:
> I'm not sure that I'd want to. Handling case insensitivity is fine
> when you're restricting everything to ASCII, but it's rather harder
> when you allow all of Unicode. For instance, U+0069 and U+0049 would
> be considered case-insensitively equal in English, but in Turkish,
> they're different letters; U+0069 upper-cases to U+0130, and U+0049
> lower-cases to U+0131. 

So what? If you're going to go out of your way to accomadate
a small regional perversion of language semantics, then your
"fetish of multiculturalism" is even more
dangerous than i have previously thought!

SPECIAL CASES ARE NOT *SPECIAL ENOUGH* TO BREAK THE RULES!

This "idea" that software needs to be written to accommodate
every language of the world is complete nonsense. I would
suggest writing software that targets *only* the modern
world. Those who refuse to be a part of the modern world can
suffer the troubles of forking the code into their ancient
systems -- and i will not loose any sleep over the issue.

PROGRESS IS MORE IMPORTANT THAN PROTECTION OF DELICATE SENSIBILITIES!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I remove/unlink wildcarded files

2015-01-02 Thread Mark Lawrence

On 02/01/2015 14:01, Chris Angelico wrote:

On Sat, Jan 3, 2015 at 12:51 AM, Ervin Hegedüs  wrote:

it may be at the concrete example in OP is better the glob - but
I think in most cases the re modul gives more flexibility, I mean
the glob modul can handle the upper/lower chars?


I'm not sure that I'd want to. Handling case insensitivity is fine
when you're restricting everything to ASCII, but it's rather harder
when you allow all of Unicode. For instance, U+0069 and U+0049 would
be considered case-insensitively equal in English, but in Turkish,
they're different letters; U+0069 upper-cases to U+0130, and U+0049
lower-cases to U+0131. Much safer, when you're writing generic tools,
to simply require case sensitivity. And you can't easily know whether
the file system is case-sensitive, case-retaining, or case-folding;
you could easily have multiple mounts that differ, so
"/home/rosuav/foo/bar/quux" might be the same as
"/home/rosuav/FOO/bar/quux", but the other four components are all
case sensitive. Yes, it really is possible.

ChrisA



Did you have to mention unicode?  Next thing you know it'll be "Is it a 
bird, is it a plane, no, it's our resident unicode expert!!!" :)


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list


Re: How do I remove/unlink wildcarded files

2015-01-02 Thread Chris Angelico
On Sat, Jan 3, 2015 at 1:10 AM, Ervin Hegedüs  wrote:
> I didn't want to solve the OP's problem - I just gave an idea.
> Here was another possible solution, I think the OP can choose the
> right one :)

Heh. Fortunately, even in cases where the OP can't recognize the right
choice, the rest of python-list will make it pretty clear :)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I remove/unlink wildcarded files

2015-01-02 Thread Ervin Hegedüs
Hi Chris,

On Sat, Jan 03, 2015 at 01:01:31AM +1100, Chris Angelico wrote:
> On Sat, Jan 3, 2015 at 12:51 AM, Ervin Hegedüs  wrote:
> > it may be at the concrete example in OP is better the glob - but
> > I think in most cases the re modul gives more flexibility, I mean
> > the glob modul can handle the upper/lower chars?
> 
> I'm not sure that I'd want to. Handling case insensitivity is fine
> when you're restricting everything to ASCII, but it's rather harder
> when you allow all of Unicode. For instance, U+0069 and U+0049 would
> be considered case-insensitively equal in English, but in Turkish,
> they're different letters; U+0069 upper-cases to U+0130, and U+0049
> lower-cases to U+0131. Much safer, when you're writing generic tools,
> to simply require case sensitivity. And you can't easily know whether
> the file system is case-sensitive, case-retaining, or case-folding;
> you could easily have multiple mounts that differ, so
> "/home/rosuav/foo/bar/quux" might be the same as
> "/home/rosuav/FOO/bar/quux", but the other four components are all
> case sensitive. Yes, it really is possible.

I didn't want to solve the OP's problem - I just gave an idea.
Here was another possible solution, I think the OP can choose the
right one :)


Cheers:

a.


-- 
I � UTF-8
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I remove/unlink wildcarded files

2015-01-02 Thread Chris Angelico
On Sat, Jan 3, 2015 at 12:51 AM, Ervin Hegedüs  wrote:
> it may be at the concrete example in OP is better the glob - but
> I think in most cases the re modul gives more flexibility, I mean
> the glob modul can handle the upper/lower chars?

I'm not sure that I'd want to. Handling case insensitivity is fine
when you're restricting everything to ASCII, but it's rather harder
when you allow all of Unicode. For instance, U+0069 and U+0049 would
be considered case-insensitively equal in English, but in Turkish,
they're different letters; U+0069 upper-cases to U+0130, and U+0049
lower-cases to U+0131. Much safer, when you're writing generic tools,
to simply require case sensitivity. And you can't easily know whether
the file system is case-sensitive, case-retaining, or case-folding;
you could easily have multiple mounts that differ, so
"/home/rosuav/foo/bar/quux" might be the same as
"/home/rosuav/FOO/bar/quux", but the other four components are all
case sensitive. Yes, it really is possible.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I remove/unlink wildcarded files

2015-01-02 Thread Ervin Hegedüs
Hi,

On Fri, Jan 02, 2015 at 11:59:17PM +1100, Chris Angelico wrote:
> On Fri, Jan 2, 2015 at 11:36 PM, Ervin Hegedüs  wrote:
> >> And worse, the given re would delete a file named "uni" which doesn't
> >> sound ANYTHING like what the OP wanted :-)
> >
> > yes, you're right - I've missed out a "." before the "*". :)
> 
> Another reason to avoid regexps when you don't actually need them.
> Globs are simpler, and have fewer obscure failure modes.

it may be at the concrete example in OP is better the glob - but
I think in most cases the re modul gives more flexibility, I mean
the glob modul can handle the upper/lower chars? 


(Anyway, now I checked the fnmatch module, which uses re module :))


Cheers:


a.


-- 
I � UTF-8
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I remove/unlink wildcarded files

2015-01-02 Thread Chris Angelico
On Fri, Jan 2, 2015 at 11:36 PM, Ervin Hegedüs  wrote:
>> And worse, the given re would delete a file named "uni" which doesn't
>> sound ANYTHING like what the OP wanted :-)
>
> yes, you're right - I've missed out a "." before the "*". :)

Another reason to avoid regexps when you don't actually need them.
Globs are simpler, and have fewer obscure failure modes.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I remove/unlink wildcarded files

2015-01-02 Thread Ervin Hegedüs
Hi,

On Fri, Jan 02, 2015 at 05:35:52AM -0600, Tim Chase wrote:
> On 2015-01-02 21:21, Cameron Simpson wrote:
> > >def unlinkFiles():
> > >dirname = "/path/to/dir"
> > >for f in os.listdir(dirname):
> > >if re.match("^unix*$", f):
> > >os.remove(os.path.join(dirname, f))
> > 
> > That is a very expensive way to check the filename in this
> > particular case. Consider:
> > 
> >   if f.startswith('unix'):
> > 
> > instead of using a regular expression.
> 
> And worse, the given re would delete a file named "uni" which doesn't
> sound ANYTHING like what the OP wanted :-)

yes, you're right - I've missed out a "." before the "*". :)



thanks:


a.


-- 
I � UTF-8
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I remove/unlink wildcarded files

2015-01-02 Thread Tim Chase
On 2015-01-02 21:21, Cameron Simpson wrote:
> >def unlinkFiles():
> >dirname = "/path/to/dir"
> >for f in os.listdir(dirname):
> >if re.match("^unix*$", f):
> >os.remove(os.path.join(dirname, f))
> 
> That is a very expensive way to check the filename in this
> particular case. Consider:
> 
>   if f.startswith('unix'):
> 
> instead of using a regular expression.

And worse, the given re would delete a file named "uni" which doesn't
sound ANYTHING like what the OP wanted :-)

-tkc


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I remove/unlink wildcarded files

2015-01-02 Thread MRAB

On 2015-01-02 10:21, Cameron Simpson wrote:

On 02Jan2015 10:00, Ervin Hegedüs  wrote:

On Thu, Jan 01, 2015 at 05:13:31PM -0600, Anthony Papillion wrote:

I have a function I'm writing to delete wildcarded files in a directory.
I tried this:

def unlinkFiles():
os.remove("/home/anthony/backup/unix*")

This doesn't seem to work because it's a wildcard filename. What is the
proper way to delete files using wildcards?


Now I didn't checked, but once I've used some like this:

def unlinkFiles():
   dirname = "/path/to/dir"
   for f in os.listdir(dirname):
   if re.match("^unix*$", f):
   os.remove(os.path.join(dirname, f))


That is a very expensive way to check the filename in this particular case.


It'll also match "uni".


Consider:

   if f.startswith('unix'):

instead of using a regular expression.

But generally the OP will probably want to use the glob module to expand the
shell pattern as suggested by others.



--
https://mail.python.org/mailman/listinfo/python-list


Re: How do I remove/unlink wildcarded files

2015-01-02 Thread Ervin Hegedüs
Hi,

On Fri, Jan 02, 2015 at 09:21:53PM +1100, Cameron Simpson wrote:
> On 02Jan2015 10:00, Ervin Hegedüs  wrote:
> >On Thu, Jan 01, 2015 at 05:13:31PM -0600, Anthony Papillion wrote:
> >>I have a function I'm writing to delete wildcarded files in a directory.
> >>I tried this:
> >>
> >>def unlinkFiles():
> >>os.remove("/home/anthony/backup/unix*")
> >>
> >>This doesn't seem to work because it's a wildcard filename. What is the
> >>proper way to delete files using wildcards?
> >
> >Now I didn't checked, but once I've used some like this:
> >
> >def unlinkFiles():
> >   dirname = "/path/to/dir"
> >   for f in os.listdir(dirname):
> >   if re.match("^unix*$", f):
> >   os.remove(os.path.join(dirname, f))
> 
> That is a very expensive way to check the filename in this
> particular case.  Consider:
> 
>  if f.startswith('unix'):
> 
> instead of using a regular expression.

well, that's true - but that works only the example above.

> But generally the OP will probably want to use the glob module to
> expand the shell pattern as suggested by others.

I didn't know the glob module before, but yes, that's better
solution for this - but as I see, that also uses os.listdir()
(and fnmatch modue).


Anyway, thanks for the tip.


a.

-- 
I � UTF-8
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Own network protocol

2015-01-02 Thread Connor

Hi,

You can use the TML/SIDEX SDK to setup a server on a Raspberry_Pi. It 
enables peer to peer communcation beased on the Blocks Extensible 
Exchange protocol. The Python interface is easy to use and you can find 
tutorial videos on youtube, how to install it on a raspberry_py.


Search for "How to install TML/SIDEX on Raspberry Pi" on youtube.

The SDK is available on multiple platforms and it is free for personal 
projects.


Cheers,
Connor

Am 27.12.2014 um 10:56 schrieb pfranke...@gmail.com:

Hello!

I am just about setting up a project with an Raspberry Pi that is connected to 
some hardware via its GPIO pins. Reading the data already works perfectly but 
now I want to distribute it to clients running in the network. Hence, I have to 
setup a server in Python.

I do not want to reinvent the wheel, so I am asking myself whether there is a 
good practice solution. It should basically work such that once value (can be 
either binary or an analog value) has changed on the server, it should send the 
update to the connected clients. At the same time, it should be possible for 
the client to send a particular request to the server as well, i.e., switch on 
LED X.

What kind of protocol do you recommend for this? UDP or TCP? Do you recommend 
the use of frameworks such as twisted?

Thanks for your input!


--
https://mail.python.org/mailman/listinfo/python-list


Re: How do I remove/unlink wildcarded files

2015-01-02 Thread Cameron Simpson

On 02Jan2015 10:00, Ervin Hegedüs  wrote:

On Thu, Jan 01, 2015 at 05:13:31PM -0600, Anthony Papillion wrote:

I have a function I'm writing to delete wildcarded files in a directory.
I tried this:

def unlinkFiles():
os.remove("/home/anthony/backup/unix*")

This doesn't seem to work because it's a wildcard filename. What is the
proper way to delete files using wildcards?


Now I didn't checked, but once I've used some like this:

def unlinkFiles():
   dirname = "/path/to/dir"
   for f in os.listdir(dirname):
   if re.match("^unix*$", f):
   os.remove(os.path.join(dirname, f))


That is a very expensive way to check the filename in this particular case.  
Consider:


 if f.startswith('unix'):

instead of using a regular expression.

But generally the OP will probably want to use the glob module to expand the 
shell pattern as suggested by others.


Cheers,
Cameron Simpson 

Each new user of a new system uncovers a new class of bugs. - Kernighan
--
https://mail.python.org/mailman/listinfo/python-list


Re: How do I remove/unlink wildcarded files

2015-01-02 Thread Ervin Hegedüs
Hi,

On Thu, Jan 01, 2015 at 05:13:31PM -0600, Anthony Papillion wrote:
> Hi Everyone,
> 
> I have a function I'm writing to delete wildcarded files in a directory.
> I tried this:
> 
> def unlinkFiles():
> os.remove("/home/anthony/backup/unix*")
> 
> This doesn't seem to work because it's a wildcard filename. What is the
> proper way to delete files using wildcards?

Now I didn't checked, but once I've used some like this:

def unlinkFiles():
dirname = "/path/to/dir"
for f in os.listdir(dirname):
if re.match("^unix*$", f):
os.remove(os.path.join(dirname, f))


a.


-- 
I � UTF-8
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I remove/unlink wildcarded files

2015-01-02 Thread Ben Finney
Anthony Papillion  writes:

> I have a function I'm writing to delete wildcarded files in a
> directory.

Is the brute-force method (explicit, easy to understand) good enough?

import os
import os.path
import glob

paths_to_remove = glob.glob(
os.path.join([
os.path.expanduser("~anthony"), "backup", "unix*"
]))
for path in paths_to_remove:
os.remove(path)

-- 
 \   “In case you haven't noticed, [the USA] are now almost as |
  `\ feared and hated all over the world as the Nazis were.” —Kurt |
_o__)   Vonnegut, 2004 |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I remove/unlink wildcarded files

2015-01-02 Thread Emil Oppeln-Bronikowski



This doesn't seem to work because it's a wildcard filename. What is the
proper way to delete files using wildcards?


You could try glob[1] and then iterate over collected list (it also 
gives you a chance to handle errors like unreadable/not owned by you files).


[1] https://docs.python.org/2/library/glob.html

--

Emil Oppeln-Bronikowski *|* http://fuse.pl
-- 
https://mail.python.org/mailman/listinfo/python-list


How do I remove/unlink wildcarded files

2015-01-02 Thread Anthony Papillion
Hi Everyone,

I have a function I'm writing to delete wildcarded files in a directory.
I tried this:

def unlinkFiles():
os.remove("/home/anthony/backup/unix*")

This doesn't seem to work because it's a wildcard filename. What is the
proper way to delete files using wildcards?

Thanks,
Anthony

-- 
Anthony Papillion

Phone:   1.918.631.7331
XMPP Chat:   cyp...@chat.cpunk.us
Fingerprint: 65EF73EC 8B57F6B1 8C475BD4 426088AC FE21B251
iNum:+883510001190960
PGP Key: http://www.cajuntechie.org/p/my-pgp-key.html
-- 
https://mail.python.org/mailman/listinfo/python-list